
clear all
************************************
*Numeric Export disabled
local TEX ""
local TEXON 0 //Change "0" to "1" to enable exporting numeric results to .txt files
if !`TEXON' local TEX "*"
*Also need to install texresults2
*ssc install texresults2
************************************

************************************
*Set working directory
************************************

*Load Gilens' data and recode variables
do "Enns_SociologicalScience_Reproduction\LoadGilensDataRecodeConfirmAccuracy.do"


*******************************************************
*******************************************************
*Table A-6, Top: Column 1
*******************************************************
*******************************************************
*Exact Replication of Gilens 2012 Column 3, Table A3.3
*Must center vars so mean of 0
*******************************************************
*******************************************************
preserve //so can restore for subsequent analyses after dropping missing values needed for matrix calculations
drop if policyadopted==.
*Save DV as vector
mkmat policyadopted, matrix(y)
gen cons=1

drop if pred10_sw==.
drop if pred50_sw==. 
drop if pred90_sw==.
*Need to standardize so mean = 0
foreach var of varlist pred10_sw pred50_sw pred90_sw {
sum `var'
gen z`var' = `var'-`r(mean)'
}

mkmat cons zpred10_sw zpred50_sw zpred90_sw, matrix(Xz)
mat def XpXz = Xz'*Xz

*Deflate covariance matrix
*create empty matrix
*Values from p.256
mat deflate = (1, 1, 1, 1 \ 1, 1, .86, .81 \ 1, .86, 1, .83 \ 1, .81, .83, 1)
*gen empty matrix
matrix XpXzdef = J(4,4,0)

forvalues i = 1/4 {
	forvalues j = 1/4 {
		matrix XpXzdef[`i',`j'] = XpXz[`i',`j']*deflate[`i',`j']
		}
	}

mat def b = invsym(XpXzdef)*Xz'*y
mat l b
local multi10 = b[2,1]
local multi50 = b[3,1]
local multi90 = b[4,1]
local multicons = b[1,1]
*****************************
**Estimate Standard Errors
mat def u = y-Xz*b

mat def sumsq = u'*u
scalar sumsq = sumsq[1,1]
local sumsq = sumsq
di `sumsq'
local sigma2 = `sumsq'/(1779-4)
di `sigma2'

mat def varcov = `sigma2'*invsym(XpXzdef)

matrix se = J(4,1,0)

forvalues i = 1/4 {
		matrix se[`i',1] = sqrt(varcov[`i',`i'])
		}
mat l se
local multi10se = se[2,1]
local multi50se = se[3,1]
local multi90se = se[4,1]
local multiconsse = se[1,1]

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multiten) result(`multi10') round(2) replace
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififty) result(`multi50') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininety) result(`multi90') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multicons) result(`multicons') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitense) result(`multi10se') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififtyse) result(`multi50se') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetyse) result(`multi90se') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multiconsse) result(`multiconsse') round(2) append
restore 
***********************************************************
*******************************************************
*Table A-6, Top: Column 2
*Using Gilens' reliabilities from p.88
***********************************************************
sem ( pred10_sw_lor <-X1) ( pred50_sw_lor <-X2) ( pred90_sw_lor <-X3) (policyadopted <- X1 X2 X3), reliab( pred10_sw_lor .77 pred50_sw_lor .8 pred90_sw_lor .77)

local multi10r = _b[policyadopted:X1]
local multi50r = _b[policyadopted:X2]
local multi90r = _b[policyadopted:X3]
local multiconsr = _b[policyadopted:_cons]
local multi10ser = _se[policyadopted:X1]
local multi50ser = _se[policyadopted:X2]
local multi90ser = _se[policyadopted:X3]
local multiconsser = _se[policyadopted:_cons]
scalar nr = e(N)

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitenreliab) result(`multi10r') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififtyreliab) result(`multi50r') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetyreliab) result(`multi90r') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetyreliabcons) result(`multiconsr') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitensereliab) result(`multi10ser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififtysereliab) result(`multi50ser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetysereliab) result(`multi90ser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetysereliabcons) result(`multiconsser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitenreliabN) result(nr) round(0) append


***********************************************************
*******************************************************
**Table A-6, Top: Column 3
**Use Reliabilities that Gilens reports 2012, p.88
**Constrain Error Covariance as described on p.255-256
******************************
cor pred10_sw_lor pred90_sw_lor, cov
local cov1090 = `r(cov_12)'*.19
cor pred50_sw_lor pred90_sw_lor, cov
local cov5090 = `r(cov_12)'*.17
cor pred10_sw_lor pred50_sw_lor, cov
local cov1050 = `r(cov_12)'*.14

sem (X1@1 -> pred10_sw_lor) (X2@1 -> pred50_sw_lor) (X3@1 ->pred90_sw_lor) (policyadopted <- X1 X2 X3), ///
reliab( pred10_sw_lor .77 pred50_sw_lor .8 pred90_sw_lor .77) ///
cov(e.pred10_sw_lor*e.pred90_sw_lor@`cov1090')  ///
cov(e.pred50_sw_lor*e.pred90_sw_lor@`cov5090')  ///
cov(e.pred10_sw_lor*e.pred50_sw_lor@`cov1050') 
mat def results = r(table)
local pvaluefityrelcov = results[4,8]
local multi10rc = _b[policyadopted:X1]
local multi50rc = _b[policyadopted:X2]
local multi90rc = _b[policyadopted:X3]
local mconsrc = _b[policyadopted:_cons]
local multi10serc = _se[policyadopted:X1]
local multi50serc = _se[policyadopted:X2]
local multi90serc = _se[policyadopted:X3]
local mconsserc = _se[policyadopted:_cons]

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(pvaluefityrelcov) result(`pvaluefityrelcov') round(2) append // save p-value to report in text
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitenreliabcov) result(`multi10rc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififtyreliabcov) result(`multi50rc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetyreliabcov) result(`multi90rc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(consreliabcov) result(`mconsrc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multitensereliabcov) result(`multi10serc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multififtysereliabcov) result(`multi50serc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(multininetysereliabcov) result(`multi90serc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(conssereliabcov) result(`mconsserc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nGPreliabcov) result(e(N)) round(0) append 



*****************************************************
*Generate Gilens' interest group favorability measure
*****************************************************

*shorten variable names for easier use
foreach var of varlist AARP- VeteransofForeignWarsoftheU_S {
 	local new = substr("`var'", 1, 24)
 	rename `var' `new'
}
*Gilens creates 3 phantom pro-abortion groups (2012, p.130; p.292 note 14)
gen phantom1 = -1*NationalRighttoLifeCommi
gen phantom2 = -1*NationalRighttoLifeCommi
gen phantom3 = -1*NationalRighttoLifeCommi

order phantom1 phantom2 phantom3, before(VeteransofForeignWarsoft)
	
*Recode interest group variables into components so they can be summed according to Gilens' formula
*SF=strongly favor
*SO=strongly oppose
foreach var of varlist AARP - VeteransofForeignWarsoft {
gen SF_`var' =1 if `var'==2
}
egen SFsum = rsum(SF_AARP - SF_VeteransofForeignWarsoft)

foreach var of varlist AARP - VeteransofForeignWarsoft {
gen F_`var' = 1 if `var'==1
}
egen Fsum = rsum(F_AARP - F_VeteransofForeignWarsoft)

foreach var of varlist AARP - VeteransofForeignWarsoft {
gen O_`var' = 1 if `var'==-1
}
egen Osum = rsum(O_AARP - O_VeteransofForeignWarsoft)

foreach var of varlist AARP - VeteransofForeignWarsoft {
gen SO_`var' = 1 if `var'==-2
}
egen SOsum = rsum(SO_AARP - SO_VeteransofForeignWarsoft)

*See Gilens 2012, 129; Gilens and Page 2014, 569
gen IGfavor = SFsum + (.5*Fsum) + 1
gen IGoppose = SOsum + (.5*Osum) + 1
gen IGnet = ln(IGfavor) - ln(IGoppose)

*Rescale all predictors to range from 0 to 1
*see Gilens and Page (2014) table notes
egen ignet01 = std01(IGnet)
egen pred50_sw_lor01 = std01(pred50_sw_lor)
egen pred90_sw_lor01 = std01(pred90_sw_lor)

*********************************************
*********************************************
*Table A-6, Bottom: Column 1
*********************************************
*********************************************
*Reproduce Gilens and Page 2014
*Table 3, Model 4
*Note: Coef and SE for interest group differ by 0.01, perhaps because
*different statistical software (AMOS) used by Gilens and Page
*********************************************
*********************************************
*Reduce covariance based on Gilens' (2012, 254-256)
cor pred50_sw_lor01 pred90_sw_lor01 if policyadopted!=., cov 
local cov5090 = `r(cov_12)'*.17
di `cov5090'
sem (L5@1 -> pred50_sw_lor01) (L9@1 -> pred90_sw_lor01) ///
(policyadopted <- L5  L9  ignet01), ///
reliab(pred50_sw_lor01 .9999 pred90_sw_lor01 .9999)  ///constrain reliabilities so model converges
cov(e.pred50_sw_lor01*e.pred90_sw_lor01@`cov5090') /// deflate covariance martrix
cov(L5*ignet01@0) // interest group measurement error not expected to correlate w/ preferences (Gilens and Page 2014, Appendix 2)

local GPn = e(N)
*betas
local GP50 = _b[policyadopted:L5]
local GP90 = _b[policyadopted:L9]
local GPig = _b[policyadopted:ignet01]
local GPcons = _b[policyadopted:_cons]
local GPdif = .56-`GPig' //coef from Gilens and Page Table 3, model 4
*se
local GP50se = _se[policyadopted:L5]
local GP90se = _se[policyadopted:L9]
local GPigse = _se[policyadopted:ignet01]
local GPconsse = _se[policyadopted:_cons]
local GPdifse = .09-`GPigse' //se from Gilens and Page Table 3, model 4
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepfifty) result(`GP50') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepninety) result(`GP90') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepig) result(`GPig') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepcons) result(`GPcons') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepfiftyse) result(`GP50se') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepninetyse) result(`GP90se') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepigse) result(`GPigse') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepconse) result(`GPconsse') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepn) result(`GPn') round(0) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPdif) result(`GPdif') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPdifse) result(`GPdifse') round(2) append
********************************************************************************
*Table A-6, Bottom: Column 2
*Gilens' Reliabilities (Gilens 2012, 88)
********************************************************************************
sem (L5@1 -> pred50_sw_lor01) (L9@1 -> pred90_sw_lor01) ///
(policyadopted <- L5  L9  ignet01), reliab(pred50_sw_lor01 .8 pred90_sw_lor01 .77)  
local GP50r = _b[policyadopted:L5]
local GP90r = _b[policyadopted:L9]
local GPigr = _b[policyadopted:ignet01]
local GPconsr = _b[policyadopted:_cons]
local GP50ser = _se[policyadopted:L5]
local GP90ser = _se[policyadopted:L9]
local GPigser = _se[policyadopted:ignet01]
local GPconsser = _se[policyadopted:_cons]

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPfiftyrel) result(`GP50r') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPninetyrel) result(`GP90r') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPigrel) result(`GPigr') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepconsrel) result(`GPconsr') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPfiftyserel) result(`GP50ser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPninetyserel) result(`GP90ser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPrepconserel) result(`GPconsser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPigserel) result(`GPigser') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nGPrel) result(e(N)) round(0) append 

********************************************************************************
*Table A-6, Bottom: Column 3
*Gilens' Reliabilities + Gilens Covariance Estimates
********************************************************************************
*Reliabilities set to near 1 to constrain parameters to allow estimation
cor pred50_sw_lor01 pred90_sw_lor01 if policyadopted!=., cov 
local cov5090 = `r(cov_12)'*.17
di `cov5090'
sem (L5@1 -> pred50_sw_lor01) (L9@1 -> pred90_sw_lor01) ///
(policyadopted <- L5  L9  ignet01), reliab(pred50_sw_lor01 .8 pred90_sw_lor01 .77)  ///
cov(e.pred50_sw_lor01*e.pred90_sw_lor01@`cov5090') ///
cov(L5*ignet01@0) // interest group measurement error not expected to correlate w/ preferences (Gilens and Page 2014, Appendix 2)

local GP50rc = _b[policyadopted:L5]
local GP90rc = _b[policyadopted:L9]
local GPigrc = _b[policyadopted:ignet01]
local GPconsrc = _b[policyadopted:_cons]
local GP50serc = _se[policyadopted:L5]
local GP90serc = _se[policyadopted:L9]
local GPigserc = _se[policyadopted:ignet01]
local GPconsserc = _se[policyadopted:_cons]

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPfiftyrelcov) result(`GP50rc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPninetyrelcov) result(`GP90rc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPigrelcov) result(`GPigrc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPconsrelcov) result(`GPconsrc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPfiftyserelcov) result(`GP50serc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPninetyserelcov) result(`GP90serc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPigserelcov) result(`GPigserc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(GPconsserelcov) result(`GPconsserc') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nGPrelcov) result(e(N)) round(0) append 





*********************************************
*********************************************
*********************************************
*********************************************
*Correlations b/t general public and income group preferences
*********************************************
cor PREDALL_SW pred10_sw pred50_sw pred90_sw
mat def cor = r(C)
local allten = cor[2,1]
local allfifty = cor[3,1]
local allninety = cor[4,1]
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allten) result(`allten') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allfifty) result(`allfifty') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allninety) result(`allninety') round(2) append
*********************************************
*********************************************
*Table 4, Column 1 and Table A-11, Column 1
*Parsimonious model
*********************************************
*********************************************
gen  predall_sw_lor = log(PREDALL_SW/(1- PREDALL_SW))
label var predall_sw_lor "log of odds ratio: PREDALL_SW"
egen predall_sw_lor01 = std01(predall_sw_lor)
logit policyadopted predall_sw_lor01 ignet01
mat def results = r(table)
scalar coefcons = results[1,3]
scalar secons = results[2,3]
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefallpars) coef(predall_sw_lor01) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(seallpars) se(predall_sw_lor01) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefigpars) coef(ignet01) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(seigpars) se(ignet01) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefconsalligpars) result(coefcons) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(seconsalligpars) result(secons) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nalligpars) result(e(N)) round(0) append 

**************************************************
*Table A-11, Column 3
*Include reliabilities (Gilens 2012, p.63 (policy) p.65 (preferences), Gilens and Page 2014, Appendix 2 (interest groups))
**************************************************
sem (Lall@1 -> predall_sw_lor01) (IG@1 -> ignet01) ///
(policyadopted <- Lall  IG), reliab(policyadopted .81 predall_sw_lor01 .82 ignet01 .87) 
*betas
local allrel = _b[policyadopted:Lall]
local igrel = _b[policyadopted:IG]
local consrel = _b[policyadopted:_cons]
*se
local allrelse = _se[policyadopted:Lall]
local igrelse = _se[policyadopted:IG]
local consrelse = _se[policyadopted:_cons]
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allrel) result(`allrel') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrel) result(`igrel') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(consrel) result(`consrel') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allrelse) result(`allrelse') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrelse) result(`igrelse') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(consrelse) result(`consrelse') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nalligrel) result(e(N)) round(0) append 
*********************************************
*********************************************
*********************************************
*Code business and mass-based separately
*********************************************
********************************************
*business and professional groups
//Airlines AmericanBankersAssociation AmericanCouncilofLifeInsurance AmericanFarmBureauFederation AmericanHospitalAssociation AmericanMedicalAssociation AssociationofTrialLawyers Automobilecompanies ChamberofCommerce Computersoftwareandhardware CreditUnionNationalAssociation Defensecontractors Electriccompanies HealthInsuranceAssociation IndependentInsuranceAgentsofAmer MotionPictureAssociationofAmeric NationalAssociationofBroadcaster NationalAssociationofHomeBuilder NationalAssociationofManufacture NationalAssociationofRealtors NationalBeerWholesalersAssociati NationalFederationofIndependentB NationalRestaurantAssociation OilCompanies PharmaceuticalResearchManufactur RecordingIndustryAssociation Securitiesandinvestmentcompanies Telephonecompanies Tobbacocompanies
*****************

*Strongly Favor
foreach var of varlist Airlines AmericanBankersAssociati AmericanCouncilofLifeIns AmericanFarmBureauFedera AmericanHospitalAssociat AmericanMedicalAssociati AssociationofTrialLawyer Automobilecompanies ChamberofCommerce Computersoftwareandhardw CreditUnionNationalAssoc Defensecontractors Electriccompanies HealthInsuranceAssociati IndependentInsuranceAgen MotionPictureAssociation NationalAssociationofBro NationalAssociationofHom NationalAssociationofMan NationalAssociationofRea NationalBeerWholesalersA NationalFederationofInde NationalRestaurantAssoci OilCompanies PharmaceuticalResearchMa RecordingIndustryAssocia Securitiesandinvestmentc Telephonecompanies Tobbacocompanies {
gen bSF_`var' =1 if `var'==2
}

egen busSFsum = rsum(bSF_Airlines bSF_AmericanBankersAssociati bSF_AmericanCouncilofLifeIns bSF_AmericanFarmBureauFedera bSF_AmericanHospitalAssociat bSF_AmericanMedicalAssociati bSF_AssociationofTrialLawyer bSF_Automobilecompanies bSF_ChamberofCommerce bSF_Computersoftwareandhardw bSF_CreditUnionNationalAssoc bSF_Defensecontractors bSF_Electriccompanies bSF_HealthInsuranceAssociati bSF_IndependentInsuranceAgen bSF_MotionPictureAssociation bSF_NationalAssociationofBro bSF_NationalAssociationofHom bSF_NationalAssociationofMan bSF_NationalAssociationofRea bSF_NationalBeerWholesalersA bSF_NationalFederationofInde bSF_NationalRestaurantAssoci bSF_OilCompanies bSF_PharmaceuticalResearchMa bSF_RecordingIndustryAssocia bSF_Securitiesandinvestmentc bSF_Telephonecompanies bSF_Tobbacocompanies)

*Favor
foreach var of varlist Airlines AmericanBankersAssociati AmericanCouncilofLifeIns AmericanFarmBureauFedera AmericanHospitalAssociat AmericanMedicalAssociati AssociationofTrialLawyer Automobilecompanies ChamberofCommerce Computersoftwareandhardw CreditUnionNationalAssoc Defensecontractors Electriccompanies HealthInsuranceAssociati IndependentInsuranceAgen MotionPictureAssociation NationalAssociationofBro NationalAssociationofHom NationalAssociationofMan NationalAssociationofRea NationalBeerWholesalersA NationalFederationofInde NationalRestaurantAssoci OilCompanies PharmaceuticalResearchMa RecordingIndustryAssocia Securitiesandinvestmentc Telephonecompanies Tobbacocompanies {
gen bF_`var' = 1 if `var'==1
}

egen busFsum = rsum(bF_Airlines bF_AmericanBankersAssociati bF_AmericanCouncilofLifeIns bF_AmericanFarmBureauFedera bF_AmericanHospitalAssociat bF_AmericanMedicalAssociati bF_AssociationofTrialLawyer bF_Automobilecompanies bF_ChamberofCommerce bF_Computersoftwareandhardw bF_CreditUnionNationalAssoc bF_Defensecontractors bF_Electriccompanies bF_HealthInsuranceAssociati bF_IndependentInsuranceAgen bF_MotionPictureAssociation bF_NationalAssociationofBro bF_NationalAssociationofHom bF_NationalAssociationofMan bF_NationalAssociationofRea bF_NationalBeerWholesalersA bF_NationalFederationofInde bF_NationalRestaurantAssoci bF_OilCompanies bF_PharmaceuticalResearchMa bF_RecordingIndustryAssocia bF_Securitiesandinvestmentc bF_Telephonecompanies bF_Tobbacocompanies)


*Oppose
foreach var of varlist Airlines AmericanBankersAssociati AmericanCouncilofLifeIns AmericanFarmBureauFedera AmericanHospitalAssociat AmericanMedicalAssociati AssociationofTrialLawyer Automobilecompanies ChamberofCommerce Computersoftwareandhardw CreditUnionNationalAssoc Defensecontractors Electriccompanies HealthInsuranceAssociati IndependentInsuranceAgen MotionPictureAssociation NationalAssociationofBro NationalAssociationofHom NationalAssociationofMan NationalAssociationofRea NationalBeerWholesalersA NationalFederationofInde NationalRestaurantAssoci OilCompanies PharmaceuticalResearchMa RecordingIndustryAssocia Securitiesandinvestmentc Telephonecompanies Tobbacocompanies {
gen bO_`var' = 1 if `var'==-1
}

egen busOsum = rsum(bO_Airlines bO_AmericanBankersAssociati bO_AmericanCouncilofLifeIns bO_AmericanFarmBureauFedera bO_AmericanHospitalAssociat bO_AmericanMedicalAssociati bO_AssociationofTrialLawyer bO_Automobilecompanies bO_ChamberofCommerce bO_Computersoftwareandhardw bO_CreditUnionNationalAssoc bO_Defensecontractors bO_Electriccompanies bO_HealthInsuranceAssociati bO_IndependentInsuranceAgen bO_MotionPictureAssociation bO_NationalAssociationofBro bO_NationalAssociationofHom bO_NationalAssociationofMan bO_NationalAssociationofRea bO_NationalBeerWholesalersA bO_NationalFederationofInde bO_NationalRestaurantAssoci bO_OilCompanies bO_PharmaceuticalResearchMa bO_RecordingIndustryAssocia bO_Securitiesandinvestmentc bO_Telephonecompanies bO_Tobbacocompanies)

*Srongly Oppose
foreach var of varlist Airlines AmericanBankersAssociati AmericanCouncilofLifeIns AmericanFarmBureauFedera AmericanHospitalAssociat AmericanMedicalAssociati AssociationofTrialLawyer Automobilecompanies ChamberofCommerce Computersoftwareandhardw CreditUnionNationalAssoc Defensecontractors Electriccompanies HealthInsuranceAssociati IndependentInsuranceAgen MotionPictureAssociation NationalAssociationofBro NationalAssociationofHom NationalAssociationofMan NationalAssociationofRea NationalBeerWholesalersA NationalFederationofInde NationalRestaurantAssoci OilCompanies PharmaceuticalResearchMa RecordingIndustryAssocia Securitiesandinvestmentc Telephonecompanies Tobbacocompanies {
gen bSO_`var' = 1 if `var'==-2
}

egen busSOsum = rsum(bSO_Airlines bSO_AmericanBankersAssociati bSO_AmericanCouncilofLifeIns bSO_AmericanFarmBureauFedera bSO_AmericanHospitalAssociat bSO_AmericanMedicalAssociati bSO_AssociationofTrialLawyer bSO_Automobilecompanies bSO_ChamberofCommerce bSO_Computersoftwareandhardw bSO_CreditUnionNationalAssoc bSO_Defensecontractors bSO_Electriccompanies bSO_HealthInsuranceAssociati bSO_IndependentInsuranceAgen bSO_MotionPictureAssociation bSO_NationalAssociationofBro bSO_NationalAssociationofHom bSO_NationalAssociationofMan bSO_NationalAssociationofRea bSO_NationalBeerWholesalersA bSO_NationalFederationofInde bSO_NationalRestaurantAssoci bSO_OilCompanies bSO_PharmaceuticalResearchMa bSO_RecordingIndustryAssocia bSO_Securitiesandinvestmentc bSO_Telephonecompanies bSO_Tobbacocompanies)


*See Gilens 2012, 129; Gilens and Page 2014, 569
gen IGfavorbusprof = busSFsum + (.5*busFsum) + 1
gen IGopposebusprof = busSOsum + (.5*busOsum) + 1
gen IGnetbusprof = ln(IGfavorbusprof) - ln(IGopposebusprof)

*Rescale all predictors to range from 0 to 1
*see Gilens and Page (2014) table notes
egen ignetbusprof01 = std01(IGnetbusprof)



*mass-based
//AARP AFLCIO AmericanFederationofStateCountya AmericanIsraelPublicAffairsCommi AmericanLegion ChristianCoalition InternationalBrotherhoodofTeamst NationalRifleAssociation NationalRighttoLifeCommittee UnitedAutoWorkersunion VeteransofForeignWarsoftheU_S phantom1 phantom2 phantom3 //*Gilens creates 3 phantom pro-abortion groups (2012, p.130; p.292 note 14) (created above)

*Strongly Favor
foreach var of varlist AARP AFLCIO AmericanFederationofStat AmericanIsraelPublicAffa AmericanLegion ChristianCoalition InternationalBrotherhood NationalRifleAssociation NationalRighttoLifeCommi UnitedAutoWorkersunion VeteransofForeignWarsoft phantom1 phantom2 phantom3 {
gen mSF_`var' =1 if `var'==2
}
egen massSFsum = rsum(mSF_AARP mSF_AFLCIO mSF_AmericanFederationofStat mSF_AmericanIsraelPublicAffa mSF_AmericanLegion mSF_ChristianCoalition mSF_InternationalBrotherhood mSF_NationalRifleAssociation mSF_NationalRighttoLifeCommi mSF_UnitedAutoWorkersunion mSF_VeteransofForeignWarsoft mSF_phantom1 mSF_phantom2 mSF_phantom3)

*Favor
foreach var of varlist AARP AFLCIO AmericanFederationofStat AmericanIsraelPublicAffa AmericanLegion ChristianCoalition InternationalBrotherhood NationalRifleAssociation NationalRighttoLifeCommi UnitedAutoWorkersunion VeteransofForeignWarsoft phantom1 phantom2 phantom3 {
gen mF_`var' =1 if `var'==1
}
egen massFsum = rsum(mF_AARP mF_AFLCIO mF_AmericanFederationofStat mF_AmericanIsraelPublicAffa mF_AmericanLegion mF_ChristianCoalition mF_InternationalBrotherhood mF_NationalRifleAssociation mF_NationalRighttoLifeCommi mF_UnitedAutoWorkersunion mF_VeteransofForeignWarsoft mF_phantom1 mF_phantom2 mF_phantom3)

*Oppose
foreach var of varlist AARP AFLCIO AmericanFederationofStat AmericanIsraelPublicAffa AmericanLegion ChristianCoalition InternationalBrotherhood NationalRifleAssociation NationalRighttoLifeCommi UnitedAutoWorkersunion VeteransofForeignWarsoft phantom1 phantom2 phantom3 {
gen mO_`var' =1 if `var'==-1
}
egen massOsum = rsum(mO_AARP mO_AFLCIO mO_AmericanFederationofStat mO_AmericanIsraelPublicAffa mO_AmericanLegion mO_ChristianCoalition mO_InternationalBrotherhood mO_NationalRifleAssociation mO_NationalRighttoLifeCommi mO_UnitedAutoWorkersunion mO_VeteransofForeignWarsoft mO_phantom1 mO_phantom2 mO_phantom3)


*Srongly Oppose
foreach var of varlist AARP AFLCIO AmericanFederationofStat AmericanIsraelPublicAffa AmericanLegion ChristianCoalition InternationalBrotherhood NationalRifleAssociation NationalRighttoLifeCommi UnitedAutoWorkersunion VeteransofForeignWarsoft phantom1 phantom2 phantom3 {
gen mSO_`var' =1 if `var'==-2
}
egen massSOsum = rsum(mSO_AARP mO_AFLCIO mSO_AmericanFederationofStat mSO_AmericanIsraelPublicAffa mSO_AmericanLegion mSO_ChristianCoalition mSO_InternationalBrotherhood mSO_NationalRifleAssociation mSO_NationalRighttoLifeCommi mSO_UnitedAutoWorkersunion mSO_VeteransofForeignWarsoft mSO_phantom1 mSO_phantom2 mSO_phantom3)

*See Gilens 2012, 129; Gilens and Page 2014, 569
gen IGfavormass = massSFsum + (.5*massFsum) + 1
gen IGopposemass = massSOsum + (.5*massOsum) + 1
gen IGnetmass = ln(IGfavormass) - ln(IGopposemass)

*Rescale all predictors to range from 0 to 1
*see Gilens and Page (2014) table notes
egen ignetmass01 = std01(IGnetmass)

*********************************************
*********************************************
*Table 4, Column 2 and Table A-11, Columnd 2
*********************************************
*********************************************
logit policyadopted predall_sw_lor01 ignetmass01 ignetbusprof01
*test of reseponsiveness to general public is statistically different from business interest groups (it's not)
mat def resultsmbig = r(table)
test _b[predall_sw_lor01]=_b[ignetbusprof01]
scalar coefconsmbig = resultsmbig[1,4]
scalar seconsmbig = resultsmbig[2,4]
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefallparsmbig) coef(predall_sw_lor01) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(seallparsmbig) se(predall_sw_lor01) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefmassigpars) coef(ignetmass01) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(semassigpars) se(ignetmass01) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefbusigpars) coef(ignetbusprof01) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(sebusigpars) se(ignetbusprof01) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(coefconsallmbigpars) result(coefconsmbig) round(2) append //coef
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(seconsallmbigpars) result(seconsmbig) round(2) append //se
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nallmbigpars) result(e(N)) round(0) append 

*********************************************
*********************************************
*Table A-11, Column 4
*********************************************
*********************************************
sem (Lall@1 -> predall_sw_lor01) (MA@1 -> ignetmass01) (B@1 -> ignetbusprof01)  ///
(policyadopted <- Lall MA B), reliab(policyadopted .81 predall_sw_lor01 .82 ignetmass01 .87 ignetbusprof01 .87) 
*m=mass, b=business
*betas
local allrelmb = _b[policyadopted:Lall]
local igrelm = _b[policyadopted:MA]
local igrelb = _b[policyadopted:B]
local consrelmb = _b[policyadopted:_cons]
*se
local allrelsemb = _se[policyadopted:Lall]
local igrelsem = _se[policyadopted:MA]
local igrelseb = _se[policyadopted:B]
local consrelsemb = _se[policyadopted:_cons]

*********************************************
*Correlations b/t general public, business interests, and mass public interests
*********************************************
cor PREDALL_SW ignetmass01 ignetbusprof01
mat def cor = r(C)
local corpubmass = cor[2,1]
local corpubbus = cor[3,1]
local cormassbus = cor[3,2]

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(corpubmass) result(`corpubmass') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(corpubbus) result(`corpubbus') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(cormassbus) result(`cormassbus') round(2) append

`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allrelmb) result(`allrelmb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrelm) result(`igrelm') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrelb) result(`igrelb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(consrelmb) result(`consrelmb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(allrelsemb) result(`allrelsemb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrelsem) result(`igrelsem') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(igrelseb) result(`igrelseb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(consrelsemb) result(`consrelsemb') round(2) append
`TEX'texresults2 using TxtFiles_NumericalResults\GP2014plus.txt, texmacro(nalligrelmb) result(e(N)) round(0) append 

